<template>
  <header class="header">
    <div class="container">
      <div class="header-content">
        <div class="logo-nav">
          <NuxtLink to="/" class="logo">例子网</NuxtLink>
          <nav class="nav">
            <NuxtLink v-for="item in navItems" :key="item.name" :to="item.href" 
              class="nav-link">
              {{ item.name }}
            </NuxtLink>
          </nav>
        </div>

        <div class="search-box">
          <input type="text" placeholder="搜索关键词/标签/作者" class="search-input">
        </div>

        <div class="user-actions">
          <button class="btn btn-secondary">登录/注册</button>
          <button class="btn btn-primary">发布</button>
        </div>
      </div>
    </div>
  </header>
</template>

<script setup>
const navItems = [
  { name: '首页', href: '/' },
  { name: '示例中心', href: '/examples' },
  { name: '项目广场', href: '/projects' },
  { name: '技术地图', href: '/tech-map' },
  { name: '贡献指南', href: '/contribute' }
]
</script>

<style scoped>
.header {
  background-color: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-nav {
  display: flex;
  align-items: center;
}

.logo {
  font-size: 24px;
  font-weight: bold;
  color: var(--text-color);
  text-decoration: none;
  margin-right: 32px;
}

.nav {
  display: flex;
  gap: 24px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 0;
  position: relative;
}

.nav-link:hover {
  color: var(--primary-color);
}

.nav-link.router-link-active {
  color: var(--primary-color);
}

.search-box {
  flex: 1;
  max-width: 400px;
  margin: 0 24px;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.user-actions {
  display: flex;
  gap: 12px;
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    height: auto;
    padding: 16px 0;
  }

  .logo-nav {
    width: 100%;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  .nav {
    display: none;
  }

  .search-box {
    width: 100%;
    max-width: none;
    margin: 16px 0;
  }

  .user-actions {
    width: 100%;
    justify-content: center;
  }
}
</style> 